/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package ar.edu.utn.frsf.cidisi.bbp.impl;

import ar.edu.utn.frsf.cidisi.bbp.BbpPackage;
import ar.edu.utn.frsf.cidisi.bbp.ClosingConstruct;
import ar.edu.utn.frsf.cidisi.bbp.Node;
import ar.edu.utn.frsf.cidisi.bbp.OpeningConstruct;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Node</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ar.edu.utn.frsf.cidisi.bbp.impl.NodeImpl#getChildren <em>Children</em>}</li>
 *   <li>{@link ar.edu.utn.frsf.cidisi.bbp.impl.NodeImpl#getId <em>Id</em>}</li>
 *   <li>{@link ar.edu.utn.frsf.cidisi.bbp.impl.NodeImpl#getOpeningSemantics <em>Opening Semantics</em>}</li>
 *   <li>{@link ar.edu.utn.frsf.cidisi.bbp.impl.NodeImpl#getClosingSemantics <em>Closing Semantics</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class NodeImpl extends EObjectImpl implements Node {
	/**
	 * The cached value of the '{@link #getChildren() <em>Children</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getChildren()
	 * @generated
	 * @ordered
	 */
	protected EList<Node> children;

	/**
	 * The default value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected static final String ID_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected String id = ID_EDEFAULT;

	/**
	 * The default value of the '{@link #getOpeningSemantics() <em>Opening Semantics</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOpeningSemantics()
	 * @generated
	 * @ordered
	 */
	protected static final OpeningConstruct OPENING_SEMANTICS_EDEFAULT = OpeningConstruct.AND;

	/**
	 * The cached value of the '{@link #getOpeningSemantics() <em>Opening Semantics</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOpeningSemantics()
	 * @generated
	 * @ordered
	 */
	protected OpeningConstruct openingSemantics = OPENING_SEMANTICS_EDEFAULT;

	/**
	 * The default value of the '{@link #getClosingSemantics() <em>Closing Semantics</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getClosingSemantics()
	 * @generated
	 * @ordered
	 */
	protected static final ClosingConstruct CLOSING_SEMANTICS_EDEFAULT = ClosingConstruct.EMPTY;

	/**
	 * The cached value of the '{@link #getClosingSemantics() <em>Closing Semantics</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getClosingSemantics()
	 * @generated
	 * @ordered
	 */
	protected ClosingConstruct closingSemantics = CLOSING_SEMANTICS_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected NodeImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BbpPackage.Literals.NODE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Node> getChildren() {
		if (children == null) {
			children = new EObjectContainmentEList<Node>(Node.class, this, BbpPackage.NODE__CHILDREN);
		}
		return children;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getId() {
		return id;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setId(String newId) {
		String oldId = id;
		id = newId;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BbpPackage.NODE__ID, oldId, id));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public OpeningConstruct getOpeningSemantics() {
		return openingSemantics;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOpeningSemantics(OpeningConstruct newOpeningSemantics) {
		OpeningConstruct oldOpeningSemantics = openingSemantics;
		openingSemantics = newOpeningSemantics == null ? OPENING_SEMANTICS_EDEFAULT : newOpeningSemantics;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BbpPackage.NODE__OPENING_SEMANTICS, oldOpeningSemantics, openingSemantics));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ClosingConstruct getClosingSemantics() {
		return closingSemantics;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setClosingSemantics(ClosingConstruct newClosingSemantics) {
		ClosingConstruct oldClosingSemantics = closingSemantics;
		closingSemantics = newClosingSemantics == null ? CLOSING_SEMANTICS_EDEFAULT : newClosingSemantics;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BbpPackage.NODE__CLOSING_SEMANTICS, oldClosingSemantics, closingSemantics));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case BbpPackage.NODE__CHILDREN:
				return ((InternalEList<?>)getChildren()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case BbpPackage.NODE__CHILDREN:
				return getChildren();
			case BbpPackage.NODE__ID:
				return getId();
			case BbpPackage.NODE__OPENING_SEMANTICS:
				return getOpeningSemantics();
			case BbpPackage.NODE__CLOSING_SEMANTICS:
				return getClosingSemantics();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case BbpPackage.NODE__CHILDREN:
				getChildren().clear();
				getChildren().addAll((Collection<? extends Node>)newValue);
				return;
			case BbpPackage.NODE__ID:
				setId((String)newValue);
				return;
			case BbpPackage.NODE__OPENING_SEMANTICS:
				setOpeningSemantics((OpeningConstruct)newValue);
				return;
			case BbpPackage.NODE__CLOSING_SEMANTICS:
				setClosingSemantics((ClosingConstruct)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case BbpPackage.NODE__CHILDREN:
				getChildren().clear();
				return;
			case BbpPackage.NODE__ID:
				setId(ID_EDEFAULT);
				return;
			case BbpPackage.NODE__OPENING_SEMANTICS:
				setOpeningSemantics(OPENING_SEMANTICS_EDEFAULT);
				return;
			case BbpPackage.NODE__CLOSING_SEMANTICS:
				setClosingSemantics(CLOSING_SEMANTICS_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case BbpPackage.NODE__CHILDREN:
				return children != null && !children.isEmpty();
			case BbpPackage.NODE__ID:
				return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
			case BbpPackage.NODE__OPENING_SEMANTICS:
				return openingSemantics != OPENING_SEMANTICS_EDEFAULT;
			case BbpPackage.NODE__CLOSING_SEMANTICS:
				return closingSemantics != CLOSING_SEMANTICS_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (id: ");
		result.append(id);
		result.append(", openingSemantics: ");
		result.append(openingSemantics);
		result.append(", closingSemantics: ");
		result.append(closingSemantics);
		result.append(')');
		return result.toString();
	}

} //NodeImpl
